package com.yuuzai.openworld.framework;

import com.yuuzai.openworld.OpenWorldObject;

public class Vector extends OpenWorldObject implements Comparable<Vector> {

	public static final int X = 0;
	public static final int Y = 1;
	public static final int Z = 2;

	private double[] v;

	public Vector() {
		v = new double[] { 0, 0, 0 };
	}

	public Vector(double x, double y) {
		this();
		setValue(x, y);
	}

	public Vector(double x, double y, double z) {
		this();
		setValue(x, y, z);
	}

	public double[] getValue() {
		return (v == null) ? null : (double[]) v.clone();
	}

	public void setValue(double x, double y) {
		setX(x);
		setY(y);
	}

	public void setValue(double x, double y, double z) {
		setValue(x, y);
		setZ(z);
	}

	public void setX(double value) {
		v[X] = value;
	}

	public double getX() {
		return v[X];
	}

	public void setY(double value) {
		v[Y] = value;
	}

	public double getY() {
		return v[Y];
	}

	public void setZ(double value) {
		v[Z] = value;
	}

	public double getZ() {
		return v[Z];
	}

	public double getLength() {
		return Math.sqrt(Math.pow(getX(), 2) + Math.pow(getY(), 2) + Math.pow(getZ(), 2));
	}

	public int compareTo(Vector o) {
		if (o == null) {
			return 1;
		}
		return 0;
	}

}
